<template>
<div>
  <div v-for="(menu, index) of data" :key="index" :class="'menu-box level-' + level">

    <!--目录-->
    <div v-if="menu.children" class="menu-item" :class="{ 'open-item': menu.open }">
      <i v-if="!menu.open" class="el-icon-caret-right" />
      <i v-if="menu.open" class="el-icon-caret-bottom" />
      <i class="el-icon-folder" />
      <span>{{menu.label}}</span>
    </div>

    <!--子集目录-->
    <div v-if="menu.children && menu.open" class="children">
      <file-tree :data="menu.children" :level="level + 1"></file-tree>
    </div>
  </div>
</div>
</template>

<script>
export default {
  name: 'FileTree',
  components: {},
  props: {
    level: {
      type: Number,
      default: 0
    },
    data: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {}
  },
  created() {
  },
  methods: {
  }
}
</script>

<style scoped lang="scss">

  .children{
    padding-left:12px;
  }
  .menu-box{
    background-color: #555;
    color:#fff;
  }
  .menu-item{
    cursor: pointer;
  }
  .open-item{
    background-color: #409EFF;
    border-bottom:1px solid #fff;
  }

  .level-0 {
    padding: 5px;
    //box-shadow: 0 12px 10px -10px #ccc;
    border-bottom: 1px solid #777;
  }

</style>
